<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/10/8 0008
  Time: 下午 6:35
  To change this template use File | Settings | File Templates.
--%>
<script  type="text/javascript"  src="js/jquery-1.12.3.min.js"></script>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body onload="a()" >
<li>
    <div class="items-Reviews" href="">
        <div class="comments-area">
            <h4>评论条数<span>${msgList.size()}</span></h4>
            <ul class="comment-list mt-30" >
                <!--新的评论模块-->
                <c:forEach items="${msgList}" var="m">
                <li id="pinglun">
                    <div class="comment-user"> <img src="images/comment-user.jpg" alt="Shopholic"> </div>
                    <div class="comment-detail" id="pl">
                        <div class="user-name">${m.user.userName}</div>
                        <div class="post-info">
                            <ul>
                                <li>${m.msgTime}</li><input id="msgid" value="${m.msgId}">
                                <li><a href="#"><i class="fa fa-reply"></i>回复</a></li>
                            </ul>
                        </div>
                        <p>${m.conTent}</p>
                    </div>
                    <!--评论下的回复-->
<%--                    <c:forEach items="${replyList}" var="r">
                    <ul class="comment-list child-comment">
                        <li>
                            <div class="comment-user"> <img src="images/comment-user.jpg" alt="Shopholic"> </div>
                            <div class="comment-detail">
                                <div class="user-name">${r.user.userName}</div>
                                <div class="post-info">
                                    <ul>
                                        <li>${r.replyTime}</li>
                                        <li><a href="#"><i class="fa fa-reply"></i>Reply</a></li>
                                    </ul>
                                </div>
                                <p>${r.conTent}</p>
                            </div>
                        </li>
                    </ul>
                    </c:forEach>--%>
                </li>
                </c:forEach>
            </ul>
        </div>
        <div class="main-form mt-30">
            <h4>发布评论</h4>
            <form >
                <div class="row mt-30 mlr_-20">
                        <div class="col-12 mb-20 plr-20">
                            <textarea cols="30" rows="3" id="MsgContent" placeholder="发布信息" required></textarea>
                        </div>
                        <div class="col-12 plr-20">
                            <button class="btn btn-color" name="submit" id="submit" type="submit">提交</button>
                        </div>
                </div>
            </form>
        </div>
    </div>
</li>

<script>
    function  a() {
        $.ajax({
            url:"GetMsgByGoodsId",
            type: "POST",
            success:function () {

            }
        })

    }

    $(function () {
        $("#submit").on("click",function () {
            $.ajax({
                url:"/AddMsgServlet",
                type:"POST",
                data:{MsgContent:$('#MsgContent').val()},
                dataType:"json",
                success:function () {

                }
            })
        })
    })

</script>

<script>
    $(function () {
            $.ajax({
                type: 'POST',
                url: 'SelectReplybyMsgId',
                data:{msgid:$("#msgid").val()},
                dataType: 'JSON',
                success: function (data) {
                    console.log(data);
                    $.each(data.replyList, function (index, obj) {
                        var $huifu =
                           /* "<ul class=\"comment-list child-comment\">" +
                            "<li>" +
                            "<div class=\"comment-user\">" + "<img src=\"images/comment-user.jpg\" alt=\"Shopholic\">" + "<div>" +
                            "<div class=\"comment-detail\">" +
                            "<div class=\"user-name\">" + obj.user.userName + "<div>" +
                            "<div class=\"post-info\">" + " <ul>" + "<li>" + obj.replyTime + "</li>" +
                            "<li>" + "<a href=\"#\">" + "<i class=\"fa fa-reply\">" + "</i>" + Reply + "</a>" + "</li>" +
                            "</ul>" +
                            "</div>" +
                            "<p>" + obj.conTent + "</p>" +
                            " </div>" +
                            "</li>" +
                            "</ul>";*/
                           "<ul>"+
                            "<li>"+obj.conTent
                            "</li>"
                            "</ul>"
                        $("#pl").append($huifu);
                    });
                }
            })
        })
</script>

